﻿using NUnit.Framework;

namespace PriceCalculator.Tests
{
  [TestFixture]
  public class CalcPrice
  {
    [Test]
    public void ExampleAsOnTheChart()
    {
      var input = new[] { 1, 2, 1, 0, 0 };
      const double expected = 3 * 0.9 * 8.0 + 1 * 8.0;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void OneBook()
    {
      var input = new[] { 0, 0, 1, 0, 0 };
// ReSharper disable ConvertToConstant.Local
      var expected = 8.0;
// ReSharper restore ConvertToConstant.Local

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoBooks()
    {
      var input = new[] { 0, 0, 0, 2, 0 };
      var expected = 16.0;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoDifferentBooks()
    {
      var input = new[] { 0, 0, 0, 1, 1 };
      var expected = 2*8.0*0.95;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void NoBooks()
    {
      var input = new[] { 0, 0, 0, 0, 0 };
      var expected = 0.0;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void AllBooksOfOneSeries()
    {
      var input = new[] { 1, 1, 1, 1, 1 };
      var expected = 5 * 0.75 * 8.0;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoSeries()
    {
      var input = new[] { 2, 2, 2, 2, 2 };
      var expected = 2*  5 * 0.75 * 8.0;

      var result = Calculator.CalcPrice(input);

      Assert.That(result, Is.EqualTo(expected));
    }

  }
}
